package Thread.demo02;

public class Four {
    /**
     * 4、两个线程调用两个对象的同步方法，其中一个方法有Thread.sleep()
     * @param args
     */
    public static void main(String[] args) {
        Number4 numberOne = new Number4();
        Number4 numberTwo = new Number4();

        new Thread(new Runnable() {
            @Override
            public void run() {
                numberOne.getOne();
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                numberTwo.getTwo();
            }
        }).start();
    }
}
class Number4  {
    public synchronized void getOne() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("one");
    }

    public synchronized void getTwo() {
        System.out.println("two");
    }
}